<%@ page language="java" contentType="text/html;charset=UTF-8" %>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested"%>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack"%>

<chiptrack:checkLogon sourcePage="userDefinedFieldsForPojectSetup.do"/>
<%@ page import="com.scalar.chiptrack.utils.ConfigManager,
                 com.scalar.chiptrack.users.Functionality,
                 com.scalar.chiptrack.users.User,
                 com.scalar.forecast.commons.Constants,
                 com.scalar.forecast.commons.SessionKeys"%>
<% String chipTracContext = "/" + ConfigManager.getChipTracContext();%>
<% User user1 = (User) session.getAttribute (SessionKeys.USER_KEY); %>
<%
    String closeThisWindow = ( String ) request.getAttribute("CloseWindow");
    String projectId = ( String ) request.getAttribute("projectId");
%>

<HTML>
<HEAD>
<TITLE> Map Project Setup Part Numbers </TITLE>
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel=stylesheet>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<SCRIPT language="JavaScript">
<% if ( ( closeThisWindow != null ) && ( closeThisWindow.equalsIgnoreCase( "CloseWindow" ) ) ) { %>
    closeWindow( window.opener.document.projectSetupForm, '<%=projectId%>' );
	window.close();
<% } %>

    function submitPage( action )
    {
        if( action == 'EDIT') {
            document.mapPartNumbersForm.action.value = "edit";
        } else if ( action == 'CONFIRM') {
            document.mapPartNumbersForm.action.value = "confirm";
            //closeWindow( window.opener.document.projectSetupForm );
        }
        document.mapPartNumbersForm.submit();
    }
    function closeWindow( form, projectId ) {
        form.action.value = "modify";
        window.opener.enableFields();
        //form['projectSetup.projectID'].value = document.mapPartNumbersForm.projectId.value;
        form['projectSetup.projectID'].value = projectId;
        form.submit();
        window.close();
    }
</SCRIPT>
<HEAD>
<BODY>
<html:form name="mapPartNumbersForm" method="post"  action="/mapPartNumbers.do" scope="session" type="com.scalar.forecast.projectSetup.forms.MapPartNumbersForm" >

<TABLE cellSpacing=0 cellPadding=0 width="100%" border="0">
  <TBODY>
  <TR>
    <TD bgcolor="#ffffff">
        <IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
        <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
        <TD valign="top" width="100%">

        <IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>

<!-- from here your body starts -->
        <center><span class="NArialW">Map Project Setup Part Numbers</span></center>
        <BR>
        <nested:nest property="mapPartNumbers">
        <TABLE border="0" align="center">
        <% if ( !user1.isActionAllowed ( Functionality.PROJECT_SETUP, User.USER_ACTION_MODIFY ) ) { %>
                <tr><td colspan=6 align='left'><font class='NArialS'><font color='blue'><b><%=Constants.NO_MODIFY_RIGHTS %></b></font></font></td></tr> <% } %>

                <TR><TD colspan =6 class="NArialL" id="errorsId"><chiptrack:errors styleClass="NArialL" /></TD></TR>
                <TR><TD colspan =6 class="NArialL" id="infoId"><chiptrack:info styleClass="NArialL" /></TD></TR>
                <!--<TR><TD colspan="6" align="left" class='NArialL'><font styleClass="NArialL" id="error" color="FF0000"/>&nbsp;</font></TD></TR>-->
                <TR>
                    <TD colspan=4 align=right>
                        <a href="javascript:submitPage('CONFIRM');"><img src="<%=chipTracContext%>/jsp/includes/images/confirm.gif" border='0'onmouseover="window.status='Click here to Confirm Mapping Part Numbers';return true" onmouseout="window.status='';return true" title="Click here to Confirm Mapping Part Numbers"></a>
                        &nbsp;&nbsp;&nbsp;&nbsp;
                        <a href="javascript:submitPage('EDIT');"><img src="<%=chipTracContext%>/jsp/includes/images/edit.gif" border=0 onmouseover="window.status='Click here to Edit Mapping Part Numbers';return true" onmouseout="window.status='';return true" title="Click here to Edit Mapping Part Numbers"></a>
                    </TD>
                </TR>
                <TD colspan=3 >
                    <FONT class=NArialL><FONT color="red"><li> Are you sure, you want to replace the part numbers for the Project?
                    <logic:present name="isForecastEntered">
                        <logic:equal value="true" name="isForecastEntered">
                            <li>And All the forecast details will be updated to the replaced part numbers.</li>
                        </logic:equal>
                    </logic:present>
                    </FONT></FONT>
                </TD>
                <TR bgColor=#993333  >
                    <TD class="NArialL" align="center"><FONT style="color:#ffffff;">Original Part No.</FONT></TD>
                    <TD>&nbsp;</TD>
                    <TD class="NArialL" align="center"><FONT style="color:#ffffff;">Replacing Part No.</FONT></TD>
				</TR>
                <logic:equal name="showChips" value="TRUE">
                    <TR><TD colspan=6 align="left" bgcolor="#AAAAFF"><FONT CLASS="NArialL">CHIPS</FONT></TD></TR>
                    <nested:iterate name="mapPartNumbers" id="chips" property="chipsList">
                    <TR>
                        <TD ><FONT CLASS="NArialL"><nested:write name="chips" property="originalPartNumber"/></FONT></TD>
                        <TD>----->&nbsp;</TD>
                        <TD><FONT CLASS="NArialL"><nested:write name ="chips" property="replacingPartNumber"/></FONT>
                             <nested:hidden name="chips" property="originalPartNumberId" />
                             <nested:hidden name="chips" property="replacingPartNumberId"/>
                        </TD>
                    </TR>
                    </nested:iterate>
                </logic:equal>
                <logic:equal name="showBoards" value="TRUE">
                    <TR><TD colspan=6 align="left">&nbsp;</TD></TR>
                    <TR><TD colspan=6 align="left" bgcolor="#AAAAFF"><FONT CLASS="NArialL">BOARDS</FONT></TD></TR>
                    <nested:iterate name="mapPartNumbers" property="boardsList" id="boards" >
                    <TR>
                        <TD ><FONT CLASS="NArialL"><nested:write name="boards" property="originalPartNumber" /></FONT> </TD>
                        <TD>----->&nbsp;</TD>
                        <TD><FONT CLASS="NArialL"><nested:write name ="boards" property="replacingPartNumber" /></FONT>
                             <nested:hidden name="boards" property="originalPartNumberId" />
                             <nested:hidden name="boards" property="replacingPartNumberId" />
                        </TD>
                    </TR>
                    </nested:iterate>
                </logic:equal>
                <logic:equal name="showKits" value="TRUE">
                    <TR><TD colspan=6 align="left">&nbsp;</TD></TR>
                    <TR><TD colspan=6 align="left" bgcolor="#AAAAFF"><FONT CLASS="NArialL">KITS</FONT></TD></TR>
                    <nested:iterate name="mapPartNumbers"  property="kitsList" id="kits">
                    <TR>
                        <TD ><FONT CLASS="NArialL"><nested:write name="kits" property="originalPartNumber" /></FONT> </TD>
                        <TD>----->&nbsp;</TD>
                        <TD><FONT CLASS="NArialL"><nested:write name ="kits" property="replacingPartNumber" /></FONT>
                            <nested:hidden name="kits" property="originalPartNumberId" />
                            <nested:hidden name="kits" property="replacingPartNumberId" />
                        </TD>
                    </TR>
                    </nested:iterate>
                </logic:equal>
                <TR> <TD>&nbsp;</TD> </TR>
                <TR> <TD colspan="6" align="center">
                    <a href="javascript:window.close();"  onMouseOver="window.status='Click here to close this window';return true" title='Click here to close this window'><font class='NArialL'><b>[Close this window]</b></font></a>
                </TD> </TR>
            </TABLE>
        </nested:nest>
        <input type="hidden" name="action" value="">
        <input type="hidden" name="projectId" value="<%=request.getParameter("projectId")%>">
    </TD>
<!-- till here -->
  </TR>
  </TBODY>
</TABLE>
</html:form>
</BODY>
</HTML>

